<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a="https://ajax4jsf.dev.java.net/ajax"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:j4j="http://javascript4jsf.dev.java.net/"
	xmlns:wiki="http://jboss.com/products/seam/wiki"
	template="../include/template.xhtml">
	<ui:define name="title">
		<h:outputText value="目录树--" />
	</ui:define>

	<ui:define name="content">
		<link type="text/css" rel="stylesheet" href="../css/global.css" />
		<br />
		<h:graphicImage value="../images/provider.bmp"></h:graphicImage>
		<h:outputText value="角色分配" class="strong"></h:outputText>
		<rich:separator lineType="double" height="2px" />
		<rich:spacer width="30px"></rich:spacer>
		<s:div styleClass="right_center">
			<s:link value="管理" view="/admin/index.xhtml" />
			<h:outputText value=" --> 目录树" />

		</s:div>

		<s:div styleClass="right_center">
			<h:form>
				<rich:tree style="width:300px" switchType="ajax" id="tree">
					<rich:recursiveTreeNodesAdaptor roots="#{categoryAction.roots}"
						var="item" nodes="#{item.children}">
						<rich:treeNode
							changeExpandListener="#{categoryAction.sendParentNode(item)}"
							nodeSelectListener="#{categoryAction.sendParentNode(item)}"
							reRender="tree" ajaxSubmitSelection="true">
							<h:outputText value="#{item.name}"></h:outputText>
							<rich:spacer width="30px" />
							<a:commandButton id="link" value="添加孩子">
								<rich:componentControl for="panel" attachTo="link"
									operation="show" event="onclick" />
							</a:commandButton>
							<a:commandButton value="删除" action="#{categoryAction.deleteCategory(item)}"></a:commandButton>
						</rich:treeNode>
					</rich:recursiveTreeNodesAdaptor>
				</rich:tree>
			</h:form>

			<rich:modalPanel id="panel" width="350" height="100">
				<f:facet name="header">
					<h:panelGroup>
						<h:outputText value="添加子节点"></h:outputText>
					</h:panelGroup>
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:outputText value="X" style="cursor:pointer" id="hideLink"></h:outputText>
						<rich:componentControl for="panel" attachTo="hideLink"
							operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<h:form>
					<h:outputText value="#{item.name}"></h:outputText>
					<br />
					<h:inputText value="#{category.name}"></h:inputText>
					<br />
					<a:commandButton id="ok"
						action="#{categoryAction.addChildNode(category)}" value="ok"
						reRender="tree">
						<rich:componentControl for="panel" attachTo="ok" operation="hide"
							event="onclick" />
					</a:commandButton>
					
				</h:form>
			</rich:modalPanel>
			
		</s:div>
	</ui:define>
</ui:composition>
